<template>
	<u-modal v-model="showMsg" :title="msgTitle" :showTip="showTip" :titleStyle="titleStyle"
		:confirmColor="confirmColor" :cancelColor="cancelColor" :content="noticeContent" :tipContent="tipContent" :showCancelButton="true" cancelText="测试" confirmText="非测试" :borderTopStyle="borderTopStyle"
		@confirm="confirm" @cancel="cancel"></u-modal>
</template>

<script>
	export default {
		data() {
			return {
				promise: null,
				noticeInfo: {},
				showTip: false,
				msgTitle: '提示',
				tipContent: '发现火情',
				titleStyle: {},
				confirmColor: '#FFFFFF',
				cancelColor: '#FFFFFF',
				borderTopStyle: {},
				borderTopStyleValue: {
					backgroundImage: `linear-gradient(269deg, #E74A50 0%, #FA805A 100%)`,
					borderRadius: '22.5px',
					margin: '0 20px 20px',
					fontFamily: 'PingFangSC-Medium',
					fontSize: '16px',
					letterSpacing: '0.32px'
				},
				sbyjTitleStyle: {
					backgroundImage: `url(https://ifire-oss.oss-cn-shanghai.aliyuncs.com/image/banner1.png)`,
					backgroundSize: 'cover',
					width: '100%',
					height: '170px'
				},
				showMsg: false,
				noticeContent: 'XX你好，今日XX时间XX建筑XX层XX区域XX位置发生火灾，请立即前往与XX协作，使用XX设备协助灭火。',
			}
		},
		props: {
			messageInfo: {
				type: Object,
				default: function() {
					return {
						name: "火情"
					}
				}
			}
		},
		methods: {
			show() {
				this.showMsg = true;
				this.noticeInfo = this.messageInfo
				console.log(this.noticeInfo)

				// 设备预警
				this.msgTitle = ''
				this.showTip = true
				this.tipContent = '设备预警'
				this.titleStyle = this.sbyjTitleStyle
				this.borderTopStyle = this.borderTopStyleValue
				this.noticeContent = this.noticeInfo.message
				this.promise = new Promise((resolve, reject) => {
					this.resolve = resolve;
					this.reject = reject;
				});
				// 返回promise对象
				return this.promise;
			},
			confirm() {
				this.utils.request("/api/app/mainInfoData/sbFire", {
					ucId: this.noticeInfo.equcid
				}, "post", "app", true).then(res => {
					console.log(res)
				}).catch(error => {
					console.log(error)
				})
			},
			cancel() {
				console.log(this.noticeInfo.modelId)
				this.utils.request("/api/app/mainInfoData/wbCheck", {
					ucId: this.noticeInfo.equcid,
					modelId: this.noticeInfo.modelId
				}, "post", "app", true).then(res => {
					console.log(res)
				}).catch(error => {
					console.log(error)
				})
			}
		}
	}
</script>

<style>
</style>
